// 初始化处理template数据
const unitConf = {
    multiLang: {
        domainName: 'uapbd',
        currentLocale: 'zh-CN',
        moduleId: 'refer_uapbd',
    },
    key: 'pk_org',
    refType: 'tree',
    refName: 'refer-000176', /* 国际化处理： 行政组织*/
    placeholder: 'refer-000176', /* 国际化处理： 行政组织*/
    refCode: 'uapbd.org.AdminOrgDefaultTreeRef',
    queryTreeUrl: '/nccloud/riaorg/ref/AdminOrgDefaultTreeRef.do',
    treeConfig: {name: ['refer-000002', 'refer-000003'], code: ['refcode', 'refname']}, /* 国际化处理： 编码,名称*/
    rootNode: {refname: 'refer-000176', refpk: 'root'}, /* 国际化处理： 行政组织*/
    isMultiSelectedEnabled: false
};

const unitField = ['hi_psnjob.pk_post', 'hi_psnjob.pk_dept', 'hi_psnjob.pk_dept.code', 'hi_psnjob.pk_post.postcode'];
const unitField2 = ['hi_psndoc_parttime.pk_dept', 'hi_psndoc_parttime.pk_dept.code', 'hi_psndoc_parttime.pk_post', 'hi_psndoc_parttime.pk_post.postcode'];

export default function setQueryMeta() {
    let meta = this.props.meta.getMeta(), that = this;
    meta.query.items.forEach(item => {
        if (item.attrcode === 'hi_psnjob.clerkcode') {
            item.queryCondition = function () {
                return {
                    pk_org: that.props.orgVal.refpk,
                    GridRefActionExt: 'nccloud.web.hrtrn.pub.sqlbuilder.RdsQryDlgPsnRefSqlBuilder'
                }
            }
        } else if (unitField.indexOf(item.attrcode) > -1) {
            unitConf.queryCondition = function () {
                return {
                    pk_org: that.props.orgVal.refpk,
                    TreeRefActionExt: 'nccloud.web.hrhi.pub.sqlbuilder.OrgRefNoPowerSqlBuilder'
                }
            };
            item.isShowUnit = true;
            item.unitProps = unitConf;
        } else if (unitField2.indexOf(item.attrcode) > -1) {
            item.isShowUnit = true;
            item.unitProps = unitConf;
        } else if (item.attrcode === 'hi_psnjob.pk_org.code' || item.attrcode === 'hi_psnjob.pk_org') {
            item.queryCondition = function () {
                return {
                    pk_org: that.props.orgVal.refpk,
                    TreeRefActionExt: 'nccloud.web.hrtrn.pub.sqlbuilder.RdsQryDlgOrgRefSqlBuilder'
                }
            };
        } else if (item.itemtype === "refer") {
            item.queryCondition = function () {
                return {
                    pk_org: that.props.orgVal.refpk
                }
            };
        }
    });
    this.props.meta.setMeta(meta);
}
